package com.pfzy.eventbusdemo

import android.util.Log
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode

/**
 * 普通类
 */
class MyObject {
    /**
     * 注册事件总线
     */
    fun registerEventBus() {
        EventBus.getDefault().register(this)
    }

    fun unRegisterEventBus() {
        EventBus.getDefault().unregister(this)
    }

    /**
     * 接收消息3
     */
    @Subscribe(threadMode = ThreadMode.POSTING)
    fun onPostingEvent(myEvent: MyEvent) {
        Log.d(TAG, "onPostingEvent: " + myEvent.msg)
    }

    companion object {
        private const val TAG = "MyObject"
    }
}